import store from '@/store'
// 查看是否存在相同
export function twoArrCludes (arr) {
  if (store.state.user.userInfo.role === 'TUPU_SYSTEM' || store.state.user.userInfo.role === 'ROLE_ADMIN') return true
  return arr.includes(store.state.user.userInfo.role)
}
// 筛选展示按钮
export function filterBtn (arr, record, fun) {
  if (fun) {
    arr = fun(arr, record)
  }
  return arr.filter(item => {
    return (!item.noShow && (store.state.user.userInfo.role === 'TUPU_SYSTEM' || store.state.user.userInfo.role === 'ROLE_ADMIN')) || ((!item.roles || item.roles.some(role => {
      return store.state.user.userInfo.role === role
    })) && (!item.noShow || !item.noShow.includes(store.state.user.userInfo.role)))
  })
}
// 筛选展示按钮
export function recordBtn (arr, record) {
  return arr.filter(item => {
    if (record instanceof Array) {
      return !item.singleData && (!item.statusValN || !record.some(val => item.statusValN.includes(val[item.status]))) && (!item.isTrue || item.isTrue.every(item => record[item]))
    } else {
      return !item.singleData && (!item.statusValN || !item.statusValN.includes(record[item.status])) && (!item.isTrue || item.isTrue.every(item => record[item]))
    }
  })
}
